import { request, requestPayment} from '../../request/index.js'
import regeneratorRuntime from '../../lib/runtime/runtime'
import { login } from '../../utils/asyncWx.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  async handleGetUserInfo (e) {
    try {
        // 1. 获取用户信息
      const { encryptedData, rawData, iv, signature } = e.detail
        // 2. 获取小程序登录后的code
      const { code } = await login()
      console.log(code)
      const loginParams = { encryptedData, rawData, iv, signature, code }
      // 3. 发送请求 获取用户token值 它自己会存到本地

      const res = await request({url: '/users/wxlogin', data: loginParams, method: "post"})
    } catch (error) {
      console.log(error)
    }
  }
})